<ui:composition template="/templates/template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="title">
       Listar
    </ui:define>

	<ui:define name="conteudo">
		<h:head>
			<h:form>
				<div align="center">
					<p:panel id="panelFiltros" header="Filtros"
						style="margin-bottom:10px; width:80%; ">

						<div align="left">
							<div>
								<p:messages id="msgs" showDetail="true" />
							</div>
							<h:panelGroup>
								<h:panelGrid columns="4">
									<h:outputLabel value="Data Inicial:" for="dataInicial" />
									<p:calendar value="#{calendarBean.date2}" id="dataInicial"
										pattern="dd/MM/yyyy" size="6" />
									<h:outputLabel value="Data Final:" for="dataFinal" />
									<p:calendar value="#{calendarBean.date2}" id="dataFinal"
										pattern="dd/MM/yyyy" size="6" />
								</h:panelGrid>

								<h:panelGrid columns="2" style="margin-bottom:10px"
									cellpadding="5">

									<h:outputText value="Status " />
									<p:selectOneRadio id="options">
										<f:selectItem itemLabel="Aberto" itemValue="1" />
										<f:selectItem itemLabel="Pago" itemValue="2" />
										<f:selectItem itemLabel="Fechado" itemValue="3" />
									</p:selectOneRadio>

								</h:panelGrid>

								<h:panelGrid columns="2" width="42%">
									<h:outputLabel value="Cpf/Cgc:" for="cpf" />
									<p:inputText id="cpf" value="#{cadastroMB.cpf}"
										style="width:60%" />
								</h:panelGrid>
							</h:panelGroup>
							<div align="right">
								<h:panelGrid columns="2">
									<p:commandButton value="Consultar"
										actionListener="#{cadastroMB.salvar}" ajax="true"
										icon="ui-icon-search" update="msgs" />
									<p:commandButton value="Limpar"
										actionListener="#{cadastroMB.salvar}" ajax="true"
										update="msgs" />

								</h:panelGrid>
							</div>
							<h:panelGrid>
							</h:panelGrid>
						</div>
					</p:panel>
				</div>


				<p:panel id="panel" header="Lista de Ordem de Servico"
					style="margin-bottom:10px; width:80%; ">

					<div align="left">
						<p:dataTable var="car" value="#{tableBean.mediumCarsModel}"
							paginator="true" rows="5" selection="#{tableBean.selectedCar}">

							<p:column selectionMode="single" />

							<p:column headerText="Nr. O.S">
            #{car.model}
        </p:column>

							<p:column headerText="Cgc/Cpf">
            #{car.year}
        </p:column>

							<p:column headerText="Nome/Fantasia">
            #{car.manufacturer}
        </p:column>

							<p:column headerText="Status">
								<div align="center">#{car.color}</div>
							</p:column>

							<f:facet name="footer">
								<p:commandButton value="Visualizar" icon="ui-icon-search"
									update=":form:displaySingle"
									oncomplete="singleCarDialog.show()" />
								<p:commandButton value="Imprimir" icon="ui-icon-print"
									update=":form:displaySingle"
									oncomplete="singleCarDialog.show()" />
								<p:commandButton value="Pagar" icon="ui-icon-disk"
									update=":form:displaySingle"
									oncomplete="confirmarPagamento.show()" />
								<p:commandButton value="Fechar" icon="ui-icon-check"
									update=":form:displaySingle"
									oncomplete="confimarFechamento.show()" />
							</f:facet>

						</p:dataTable>

						<p:dialog header="Detalhe O.S" widgetVar="singleCarDialog"
							resizable="false" showEffect="fade" hideEffect="explode">

							<h:panelGrid id="displaySingle" columns="2" cellpadding="4">

								<f:facet name="header">
									<p:graphicImage
										value="/images/cars/#{tableBean.selectedCar.manufacturer}.jpg" />
								</f:facet>

								<h:outputText value="Nr O.s:" />
								<h:outputText value="#{tableBean.selectedCar.model}" />

								<h:outputText value="Cgc/Cpf" />
								<h:outputText value="#{tableBean.selectedCar.year}" />

								<h:outputText value="Nome/Fantasia" />
								<h:outputText value="#{tableBean.selectedCar.manufacturer}" />

								<h:outputText value="Status" />
								<h:outputText value="#{tableBean.selectedCar.color}" />

								<h:outputText value="Observacao" />
								<h:outputText value="#{tableBean.selectedCar.color}" />
							</h:panelGrid>
						</p:dialog>

						<p:confirmDialog message="Confirma o Pagamento da O.S ?"
							header="Pagamento O.S" severity="alert"
							widgetVar="confirmarPagamento">

							<p:commandButton value="Sim" update="messages"
								oncomplete="confirmarPagamento.hide()"
								actionListener="#{buttonBean.destroyWorld}" />
							<p:commandButton value="Nao" onclick="confirmarPagamento.hide()"
								type="button" />

						</p:confirmDialog>

						<p:confirmDialog message="Confirma o Fechamento da O.S ?"
							header="Fechamento O.S" severity="alert"
							widgetVar="confimarFechamento">

							<p:commandButton value="Sim" update="messages"
								oncomplete="confirmarFechamento.hide()"
								actionListener="#{buttonBean.destroyWorld}" />
							<p:commandButton value="Nao" onclick="confirmarFechamento.hide()()"
								type="button" />

						</p:confirmDialog>
					</div>
				</p:panel>

			</h:form>
		</h:head>
	</ui:define>
</ui:composition>